# Cairo智能合约助手 - 便捷命令

.PHONY: help install dev test clean lint format

# 默认目标
help:
	@echo "Cairo智能合约助手 - 可用命令:"
	@echo "  make install    - 安装依赖"
	@echo "  make dev        - 启动开发环境"
	@echo "  make api        - 启动API服务"
	@echo "  make ui         - 启动UI界面"
	@echo "  make test       - 运行测试"
	@echo "  make lint       - 代码检查"
	@echo "  make format     - 代码格式化"
	@echo "  make clean      - 清理临时文件"

# 安装依赖
install:
	pip install -r requirements.txt

# 开发环境（同时启动API和UI）
dev:
	@echo "启动开发环境..."
	@echo "API服务: http://localhost:8000"
	@echo "UI界面: http://localhost:8501"
	@echo "按 Ctrl+C 停止服务"
	@make -j2 api ui

# 启动API服务
api:
	@echo "启动API服务..."
	uvicorn api.main:app --reload --host 0.0.0.0 --port 8000

# 启动UI界面
ui:
	@echo "启动UI界面..."
	streamlit run ui/streamlit_app.py --server.port 8501

# 运行测试
test:
	pytest tests/ -v

# 代码检查
lint:
	black --check .
	isort --check-only .

# 代码格式化
format:
	black .
	isort .

# 清理临时文件
clean:
	find . -type f -name "*.pyc" -delete
	find . -type d -name "__pycache__" -delete
	find . -type d -name "*.egg-info" -exec rm -rf {} +
	rm -rf .pytest_cache/
	rm -rf logs/
